<template>
    <div style="border: 1px #e8e8e8 solid;padding: 10px;border-radius: 5px;margin-bottom: 20px">
        <div style="margin-bottom: 10px">
            <label>应用入口</label>
        </div>
        <div>
            <div @click="navToCms" class="fast-entry" style="width: 200px" :style="{background: cms_installed ? '-webkit-linear-gradient(-235deg, white, #003399)' : '-webkit-linear-gradient(-235deg, white, grey)'}">
                <div style="font-size: 20px">CMS内容管理</div>
                <div style="text-align: right;padding-bottom: 5px; margin-top: -10px" :style="{color: cms_installed ? '#003399' : 'grey'}"><i class="iconfont icon-icon_jianyiyufankui" style="font-size: 20px"></i></div>
            </div>
            <div @click="navToShop" class="fast-entry" style="width: 200px" :style="{background: shop_installed ? '-webkit-linear-gradient(-235deg, white, #008B8B)' : '-webkit-linear-gradient(-235deg, white, grey)'}">
                <div style="font-size: 20px">电子商城</div>
                <div style="text-align: right;padding-bottom: 5px; margin-top: -10px" :style="{color: shop_installed ? '#008B8B' : 'grey'}"><i class="iconfont icon-31quanbushangpin" style="font-size: 20px"></i></div>
            </div>
            <div @click="navToErp" class="fast-entry" style="width: 200px" :style="{background: erp_installed ? '-webkit-linear-gradient(-235deg, white, #2E8B57)' : '-webkit-linear-gradient(-235deg, white, grey)'}">
                <div style="font-size: 20px">ERP系统</div>
                <div style="text-align: right;padding-bottom: 5px; margin-top: -10px" :style="{color: erp_installed ? '#2E8B57' : 'grey'}"><i class="iconfont icon-icon" style="font-size: 20px"></i></div>
            </div>
            <div @click="navToIot" class="fast-entry" style="width: 200px" :style="{background: iot_installed ? '-webkit-linear-gradient(-235deg, white, #ff6a6a)' : '-webkit-linear-gradient(-235deg, white, grey)'}">
                <div style="font-size: 20px">IOT系统</div>
                <div style="text-align: right;padding-bottom: 5px; margin-top: -10px" :style="{color: iot_installed ? '#ff6a6a' : 'grey'}"><i class="iconfont icon-wulianwang" style="font-size: 20px"></i></div>
            </div>
        </div>
    </div>
</template>

<script>
import { query } from '@/app/api/install'

export default {
    data() {
        return {
            cms_installed: false,
            shop_installed: false,
            erp_installed: false,
            iot_installed: false
        }
    },
    created() {
        query({
            identity: 'open-cms'
        }).then(res => {
            if(res.errorCode == 200) {
                this.cms_installed = true
            }
        })
        query({
            identity: 'open-shop'
        }).then(res => {
            if(res.errorCode == 200) {
                this.shop_installed = true
            }
        })
        query({
            identity: 'open-erp'
        }).then(res => {
            if(res.errorCode == 200) {
                this.erp_installed = true
            }
        })
        query({
            identity: 'open-iot'
        }).then(res => {
            if(res.errorCode == 200) {
                this.iot_installed = true
            }
        })
    },
    methods: {
        navToCms() {
            if(this.cms_installed === true) {
                window.location.href = window.location.origin + '/html/cms/admin'
            } else {
                this.$router.push('/system/app')
            }
        },
        navToShop() {
            if(this.shop_installed === true) {
                window.location.href = window.location.origin + '/html/shop/admin'
            } else {
                this.$router.push('/system/app')
            }
        },
        navToErp() {
            if(this.erp_installed === true) {
                window.location.href = window.location.origin + '/html/erp/admin'
            } else {
                this.$router.push('/system/app')
            }
        },
        navToIot() {
            if(this.iot_installed === true) {
                window.location.href = window.location.origin + '/html/iot/admin'
            } else {
                this.$router.push('/system/app')
            }
        }
    }
}
</script>

<style scoped lang="scss">
@import "~@/common/iconfont/iconfont.css";

.fast-entry {
    display: inline-block;
    margin-right: 25px;
    cursor: pointer;
    width: 150px;
    text-align: center;
    background-color: #f3f3f3;
    border-radius: 5px;
    padding: 20px 10px 5px 10px;
}
</style>